package io.kiki.sba.registry.common.model.dataserver;


import io.kiki.sba.registry.common.model.ClientToClientInterfaceServerNodeId;
import io.kiki.sba.registry.common.model.RegisterVersion;
import io.kiki.sba.registry.common.model.store.Publisher;
import lombok.Getter;

import java.io.Serializable;
import java.util.HashMap;
import java.util.Map;

/**
 * request to remove data of specific clients immediately
 */
@Getter
public final class ClientOffPublisher implements Serializable {
    private static final long serialVersionUID = 1L;

    private final ClientToClientInterfaceServerNodeId clientToClientInterfaceServerNodeId;
    private final Map<String, Map<String, RegisterVersion>> publisherMap = new HashMap<>();

    public ClientOffPublisher(ClientToClientInterfaceServerNodeId clientToClientInterfaceServerNodeId) {
        this.clientToClientInterfaceServerNodeId = clientToClientInterfaceServerNodeId;
    }

    public void addPublisher(Publisher publisher) {
        Map<String, RegisterVersion> map = publisherMap.computeIfAbsent(publisher.getDataInfoId(), k -> new HashMap<>());
        map.put(publisher.getRegisterId(), publisher.registerVersion());
    }

    public boolean isEmpty() {
        return publisherMap.isEmpty();
    }


}
